<?php

foreach ($ratings as $rating) {
	echo '<div>';
	$this->widget('CStarRating', array(
		'name' => 'Rating[' . $rating->ratingTypeid . ']',
		'value' => $this->setValue((int) $this->id),
		'minRating' => 1,
		'maxRating' => 5,
		'starCount' => 5,
		'allowEmpty' => false,
		'callback' => '
        function(){
                $.ajax({
                    type: "POST",
                    url: "/main/ajax/rating",
                    data: "' . Yii::app()->request->csrfTokenName . '=' . Yii::app()->request->csrfToken . '&type=model&ratingId=' . $rating->ratingTypeid . '&modelId=' . $this->id . '&rate=" + $(this).val(),
                    success: function(msg){
					if(msg != "error"){
					var m = JSON.parse(msg);
					$("span[itemprop=average]").text(m.count);
					$("span[itemprop=votes]").text(m.allCount);
                               mobi03.showMessage("Поздравляем!", "Спасибо, Ваш отзыв успешно отправлен!");
							   }
							   else
							   mobi03.showMessage("", "Вы уже голосовали!");
                        }})}',
	));
	echo '</div>';
}
//echo '<input type="hidden" name="Ratings" value="' . CHtml::encode(json_encode($rats)) . '">';
?>